var e = getApp();

Page({
    data: {
        code: "",
        type_name: "",
        price: "",
        isShowType: !1,
        isDisabled: !1
    },
    onLoad: function(o) {
        if (o.qrCode && this.setData({
            qrCode: o.qrCode
        }), o.scene) {
            var t = decodeURIComponent(o.scene);
            if (console.log(t), t) {
                var n = [];
                n = t.split("&"), console.log(n);
                for (var i = 0; i < n.length; i++) {
                    var a;
                    "k" == (a = n[i].split("="))[0] && this.setData({
                        code: a[1]
                    }), "mid" == a[0] && e._setMid(a[1]);
                }
            }
        }
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    codecheck: function(e) {
        var o = e.detail.value;
        this.setData({
            code: o.trim()
        });
    },
    codeinp: function(e) {
        var o = e.detail.value;
        this.setData({
            code: o.trim()
        });
    },
    verifyCode: function() {
        if (e._isTextEmpty(this.data.code)) wx.showToast({
            icon: "none",
            title: "请填写充值码",
            duration: 1500
        }); else {
            var o = this, t = e.getNetAddresss("plugin.recharge-code.frontend.code.get-recharge-code");
            t += "&code_key=" + this.data.code, e._getNetWork({
                url: t,
                success: function(e) {
                    var t = e.data;
                    1 == t.result ? o.setData({
                        isShowType: !0,
                        type_name: t.data.recharge_code.type_name,
                        price: t.data.recharge_code.price
                    }) : wx.showToast({
                        icon: "none",
                        title: t.msg,
                        duration: 1500
                    });
                },
                fail: function(e) {
                    console.log(e);
                }
            });
        }
    },
    submit: function() {
        if (e._isTextEmpty(this.data.code)) wx.showToast({
            icon: "none",
            title: "请填写充值码",
            duration: 1500
        }); else {
            var o = this, t = e.getNetAddresss("plugin.recharge-code.frontend.code.recharge");
            t += "&code_key=" + this.data.code, e._getNetWork({
                url: t,
                success: function(t) {
                    var n = t.data;
                    o.setData({
                        isDisabled: !0
                    }), 1 == n.result ? e._isTextEmpty(n.data.jump_url) ? (console.log("空的"), wx.showToast({
                        title: n.msg,
                        icon: "none",
                        duration: 1500,
                        success: function() {
                            setTimeout(function() {
                                wx.reLaunch({
                                    url: "/packageG/index/index"
                                });
                            }, 1500);
                        }
                    })) : (console.log("不空的"), wx.showToast({
                        title: n.msg,
                        icon: "none",
                        duration: 1500,
                        success: function() {
                            setTimeout(function() {
                                wx.navigateTo({
                                    url: n.data.jump_url,
                                    icon: "none"
                                });
                            }, 1500);
                        }
                    })) : wx.showToast({
                        icon: "none",
                        title: n.msg,
                        duration: 1500
                    });
                },
                fail: function(e) {
                    console.log(e);
                }
            });
        }
    }
});